<?php
$points = new Pod('points');
$points->page = 1;
$points->search = false;
$points->findRecords("(login + registration + comments + deals + like_fb + feedback + vote + referral) DESC, p.modified ASC", '50','user.paid_affiliate IS NULL');
$i = 0;
while($points->fetchRecord()){
   $user[$i]['wp_id'] = $points->get_field('user.wp_user.ID');
   $name = $points->get_field('user.name');
   $name = explode(' ',$name);
   $user[$i]['name'] = $name[0];
   $user[$i]['slug'] = $points->get_field('user.slug');
   $user[$i]['total_points'] = $points->get_field('login') + $points->get_field('registration') + $points->get_field('comments') + $points->get_field('deals') + $points->get_field('like_fb') + $points->get_field('feedback') + $points->get_field('vote') + $points->get_field('referral');
   $user[$i]['modified'] = $points->get_field('modified');
   $i++;
}

//$sorted_users = array_orderby($user, 'total_points', SORT_DESC, 'modified', SORT_ASC);

echo '<h1 style="text-align: center;">Leaderboard</h1><div class="leader_wrap_page">';
foreach($user as $key=>$val){
  $wp_id = $val['wp_id'];
  
  echo '<div class="member_page">
  <div class="member_link_page">
  #'.($key + 1).' <a href="'.BUZZR_URL.'/member/'.$val['slug'].'">'.substr($val['name'],0,12).' </a>
  </div>
  <div class="salut_image_leader">'.get_avatar($wp_id,'50').'</div>
  <div class="member_points_page">'.$val['total_points'].' Points</div>
  </div>';
}
echo '</div>';
?>